import { http } from "@/utils/http";
import { ComStatus } from "./model";

/**
 * KeywordQueryDto
 */
export interface KeywordQueryDto {
  keyword: string | null;
}
export interface CategoryListItemResult {
  id: number;
  name: string;
  isVisible: boolean;
  parentId: number;
  status: ComStatus;
  createTime: string;
}
export interface CategoryResult {
  id: number;
  name: string;
  parentId: number;
  status: ComStatus;
  /** 是否可见*/
  isVisible: boolean;
  description: string | null;
  sort: number | null;
}
export interface CategoryEditRequest {
  id: number | null;
  name: string | null;
  parentId: number | null;
  status: ComStatus | null;
  /** 是否可见*/
  isVisible: boolean;
  description: string | null;
  sort: number | null;
}

export class CategoryApi {
  /**
   * 无
   */
  public list(
    param1?: KeywordQueryDto
  ): Promise<Array<CategoryListItemResult>> {
    return http.request({
      url: "/api/blog/category/list",
      method: "post",
      data: param1
    });
  }
  public get(id?: number): Promise<CategoryResult> {
    return http.request({
      url: "/api/blog/category/get",
      method: "post",
      params: { id }
    });
  }
  public edit(param1?: CategoryEditRequest): Promise<void> {
    return http.request({
      url: "/api/blog/category/edit",
      method: "post",
      data: param1
    });
  }
}
export default new CategoryApi();
